﻿namespace Arms.Presentation.Web.App_Start
{
    using Ninject;
    using System;
    using System.Web.Mvc;
    using System.Web.Routing;

    public class NinjectControllerFactory : DefaultControllerFactory
    {
        private IKernel _kernel;
        public NinjectControllerFactory(IKernel kernel)
        {
            _kernel = kernel;
        }

        protected override IController GetControllerInstance(RequestContext requestContext, Type controllerType)
        {
            return (controllerType == null) ? null : (IController)_kernel.Get(controllerType);
        }
    }
}
